    layui.use(['laydate','table'],function() {
    		var laydate,table,
    		start,end,
    		$username,$search,
    		userPage={};
    		
    		//初始化组件
    		userPage.init=function(){
    			laydate = layui.laydate;
    			table = layui.table;
    			
    			
    			start = laydate.render({
                    elem: '#start', //指定元素
                    format: 'yyyy-MM-dd',
                    done:function(value, date,endDate){
                    	end.config.min = {
                           year: date.year,
                           month: date.month - 1,
                           date: date.date,
                           hours: date.hours,
                           minutes: date.minutes,
                           seconds: date.seconds
                       }; 
                    }
                    
                });
    			
    			end = laydate.render({
                    elem: '#end' ,//指定元素
                    format: 'yyyy-MM-dd',
                    done:function(value, date,endDate){
                    	 start.config.max = {
                             year: date.year,
                             month: date.month - 1,
                             date: date.date,
                             hours: date.hours,
                             minutes: date.minutes,
                             seconds: date.seconds
                         }; 
                    }
                });
    			
                table.render({
                	id:"userTable",
                    elem: '#userTable',
                    toolbar:"#toolbar",
                    defaultToolbar:[],
                    height: 312,
                    url: contextPath+'/user/queryUserPage' ,
                    method: 'POST',
                    page: true, //开启分页
                    cols: [[ //表头
                      {checkbox: true,width:50, fixed: true},
                      {field: 'id', title: 'ID', width:80}
                      ,{field: 'userName', title: '用户名', minWidth:80}
                      ,{field: 'nickName', title: '昵称', minWidth:100}
                      ,{field: 'deptId', title: '部门', minWidth:80} 
                      ,{field: 'disabled', title: '状态', width: 80,templet:function(d){
                    	     return d.disabled == 1 ? "禁用" : "启用";
                      		}
                      }
                      ,{field: 'createTime', title: '创建时间', minWidth: 80}
                      ,{field:'right', title: '操作',minWidth:80,fixed: 'right',templet:function(d){
                    	  var html = '<a class="layui-btn layui-btn-primary layui-btn-mini" lay-event="detail">查看</a>'+
                    		    '<a class="layui-btn layui-btn-mini" lay-event="edit">编辑</a>';
                    	  if(d.disabled == 1){
                    		  html += '<a class="layui-btn  layui-btn-normal layui-btn-mini" lay-event="changeStaus">启用</a>';
                    	  }else{
                    		  html += '<a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="changeStaus">禁用</a>';
                    	  }
                    		    
                 	     return html;
                		}
                      }
                    ]],
                    where:{//其他参数
                    },
                    request: {
                        pageName: 'pageNum' //页码的参数名称，默认：page
                        ,limitName: 'pageSize' //每页数据量的参数名，默认：limit
                      },
                    response: {
                        statusName: 'code', //规定数据状态的字段名称，默认：code
                        statusCode: 1, //规定成功的状态码，默认：0
                        msgName: 'hint', //规定状态信息的字段名称，默认：msg
                        countName: 'count', //规定数据总数的字段名称，默认：count
                        dataName: 'data' //规定数据列表的字段名称，默认：data
                      } 
                    ,parseData: function(res){ //res 即为原始返回的数据
                        return {
                          "code": res.code , //解析接口状态
                          "msg": res.msg, //解析提示文本
                          "count": res.data.total, //解析数据长度
                          "data": res.data.list //解析数据列表
                        };
                      }
                  });
                
                
                $search = $("#search");
                $username = $("#username");
                
                
                userPage.bindEvent();
    			
    		}
    		
    		//绑定事件
    		userPage.bindEvent=function(){
    			//搜索
        		$search.on('click',function(){
        			reloadTable();
                });
                
              //表格工具条事件
                table.on('tool(userTableFilter)', function(obj){
                  switch(obj.event){
                    case 'detail':
                      layer.alert('查看'+obj.data.nickName);
                    break;
                    case 'edit':
                      layer.alert('编辑');
                    break;
                    case 'del':
                      layer.alert('删除');
                    break;
                    case 'changeStaus':
                        layer.alert('启用');
                      break;
                  };
                });
                
                
                //表头工具条
                table.on('toolbar(userTableFilter)', function(obj){
                	//获取选中数据 
                	var checkStatus = table.checkStatus('userTable');
                	
                    switch(obj.event){
                    	case 'add':
                    		layer.alert('新增'+obj.data);
                    		break;
                    	case 'del':
	                        layer.alert('删除');
	                        break;
                    };
                  });
    		}
    		
    		
    		function changeStaus(id,status){
    			
    		}
    		
    		function del(ids){
    			
    		}
    		
    		

    		/**
    		 * 刷新表格
    		 */
    		function reloadTable(pageNo){
    			pageNo = pageNo | 1;
    			
    			table.reload('userTable', {
                	where:{//其他参数
                    	startCreateTime:$('#start').val(),
                    	endCreateTime:$('#end').val(),
                    	disabled:$("#disabled").val(),
                    	username:$username.val()
                    },
                    page: {
                        curr: pageNo //重新从第 1 页开始
                      }
            	});
    		}
            

    		userPage.init();
        });